package com.simple.middle.test.redis.statistic.service.impl;

import com.simple.middle.test.redis.constant.UserStatisticConstant;
import com.simple.middle.test.redis.statistic.model.data.UserGeoData;
import com.simple.middle.test.redis.statistic.model.param.UserGeoParam;
import com.simple.middle.test.redis.statistic.service.UserGeoService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.GeoOperations;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 项目: pagination
 *
 * 功能描述:
 *
 * @author: WuChengXing
 *
 * @create: 2023-05-30 14:07
 **/
@Data
@Slf4j
public class UserGeoServiceImpl implements UserGeoService {

    @Resource
    private RedisTemplate redisTemplate;

    private GeoOperations geoOperations = redisTemplate.opsForGeo();

    @Override
    public Boolean addUserGeo(UserGeoParam param) {
        if (Objects.isNull(param.getUserKey())) {
            log.error("用户id不能为空");
            return false;
        }
        if (Objects.isNull(param.getLatitude())) {
            log.error("用户位置纬度不能为空");
            return false;
        }
        if (Objects.isNull(param.getLongitude())) {
            log.error("用户位置经度不能为空");
            return false;
        }
        String userKey = UserStatisticConstant.USER_POSITION_PREFIX + param.getUserKey();
        return null;
    }

    @Override
    public Boolean updateUserGeo(UserGeoParam param) {
        return null;
    }

    @Override
    public Boolean deleteUserGeo(UserGeoParam param) {
        return null;
    }

    @Override
    public List<UserGeoData> nearbyNUser(UserGeoParam param) {
        return null;
    }
}
